<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<meta http-equiv="cache-control" content="no-cache">
<title>Genivia - Code Example 1: Finding a service</title>
<link href="genivia_tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css">
<link href="genivia_content.css" rel="stylesheet" type="text/css">
</head>
<body>
<div id="top">
 <div id="titlearea">
  <table height="72px" width="100%" cellspacing="0" cellpadding="0">
   <tbody>
    <tr>
     <td width="10%">&nbsp;</td>
     <td width="175px"><a href="http://www.genivia.com"><img alt="Genivia" src="GeniviaLogo2_trans_noslogan.png"/></a></td>
     <td class="tab_home"><a href="http://www.genivia.com">Home</a></td>
     <td class="tab_home"><a href="http://www.genivia.com/docs.html">Documentation</a></td>
     <td>
      <div style="float: right; font-size: 18px; font-weight: bold;">Code Example 1: Finding a service</div>
      <br>
      <div style="float: right; font-size: 10px;">updated Mon Feb 22 2016</div>
     </td>
     <td width="10%">&nbsp;</td>
    </tr>
   </tbody>
  </table>
 </div>
<!-- Generated by Doxygen 1.8.10 -->
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li class="current"><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li><a href="files.html"><span>Files</span></a></li>
    </ul>
  </div>
</div><!-- top -->
<div class="header">
  <div class="headertitle">
<div class="title">Code Example 1: Finding a service </div>  </div>
</div><!--header-->
<div class="contents">
<div class="textblock"><p>This example shows you how to find Web services. In this case, the example finds Web services with names that begin with the word "magic".</p>
<div class="fragment"><div class="line"><span class="preprocessor">#include &quot;inqH.h&quot;</span></div>
<div class="line"></div>
<div class="line"><span class="keywordtype">int</span> main(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span> **argv)</div>
<div class="line">{ </div>
<div class="line">  <span class="keywordtype">char</span> *search_string = <span class="stringliteral">&quot;magic&quot;</span>;</div>
<div class="line"></div>
<div class="line">  <span class="keywordflow">if</span> (argc &gt; 1)</div>
<div class="line">    search_string = argv[1];</div>
<div class="line"></div>
<div class="line">  <span class="comment">// Create a gSOAP context</span></div>
<div class="line">  <span class="keyword">struct </span>soap *soap = soap_new();</div>
<div class="line"></div>
<div class="line">  <span class="comment">// Create an object to find a business</span></div>
<div class="line">  <a class="code" href="classuddi2____find___u_s_c_o_r_eservice.html">uddi2__find_USCOREservice</a> fs(soap, search_string);</div>
<div class="line"></div>
<div class="line">  <span class="comment">// Send the request</span></div>
<div class="line">  <a class="code" href="classuddi2____service_list.html">uddi2__serviceList</a> *sl = fs.send(<span class="stringliteral">&quot;http://uddi.xmethods.net/inquire&quot;</span>);</div>
<div class="line"></div>
<div class="line">  <span class="comment">// Check if result is OK</span></div>
<div class="line">  <span class="keywordflow">if</span> (!sl)</div>
<div class="line">    soap_print_fault(soap, stderr);</div>
<div class="line"></div>
<div class="line">  <span class="comment">// If OK, report the service name(s) and unique identification keys</span></div>
<div class="line">  <span class="keywordflow">else</span> <span class="keywordflow">if</span> (sl-&gt;<a class="code" href="classuddi2____service_list.html#acb6b5ff5db8e84d78d7d37f8fb60a586">serviceInfos</a>)</div>
<div class="line">  {</div>
<div class="line">    std::cout &lt;&lt; <span class="stringliteral">&quot;Search results on &quot;</span> &lt;&lt; search_string &lt;&lt; <span class="stringliteral">&quot;:&quot;</span> &lt;&lt; std::endl &lt;&lt; std::endl;</div>
<div class="line"></div>
<div class="line">    <span class="keywordflow">for</span> (std::vector&lt;uddi2__serviceInfo*&gt;::const_iterator si = sl-&gt;<a class="code" href="classuddi2____service_list.html#acb6b5ff5db8e84d78d7d37f8fb60a586">serviceInfos</a>-&gt;<a class="code" href="classuddi2____service_infos.html#abcf386a2250cbc23cf58d7119643ca5f">serviceInfo</a>.begin(); si != sl-&gt;<a class="code" href="classuddi2____service_list.html#acb6b5ff5db8e84d78d7d37f8fb60a586">serviceInfos</a>-&gt;<a class="code" href="classuddi2____service_infos.html#abcf386a2250cbc23cf58d7119643ca5f">serviceInfo</a>.end(); ++si)</div>
<div class="line">    {</div>
<div class="line">      <span class="comment">// Report serviceKey and businessKey</span></div>
<div class="line">      std::cout &lt;&lt; <span class="stringliteral">&quot;serviceKey=&quot;</span> &lt;&lt; (*si)-&gt;serviceKey &lt;&lt; std::endl &lt;&lt; <span class="stringliteral">&quot;businessKey=&quot;</span> &lt;&lt; (*si)-&gt;businessKey &lt;&lt; std::endl;</div>
<div class="line"></div>
<div class="line">      <span class="comment">// Report names</span></div>
<div class="line">      <span class="keywordflow">for</span> (std::vector&lt;uddi2__name*&gt;::const_iterator n = (*si)-&gt;name.begin(); n != (*si)-&gt;name.end(); ++n)</div>
<div class="line">        std::cout &lt;&lt; <span class="stringliteral">&quot;name=&quot;</span> &lt;&lt; (*n)-&gt;__item &lt;&lt; std::endl;</div>
<div class="line"></div>
<div class="line">      std::cout &lt;&lt; std::endl;</div>
<div class="line">    }</div>
<div class="line">  }</div>
<div class="line"></div>
<div class="line">  <span class="comment">// Remove deserialized objects</span></div>
<div class="line">  soap_destroy(soap);</div>
<div class="line"></div>
<div class="line">  <span class="comment">// Remove temporary data</span></div>
<div class="line">  soap_end(soap);</div>
<div class="line"></div>
<div class="line">  <span class="comment">// Detach and free context</span></div>
<div class="line">  soap_done(soap);</div>
<div class="line">  free(soap);</div>
<div class="line"></div>
<div class="line">  <span class="keywordflow">return</span> 0;</div>
<div class="line">}</div>
</div><!-- fragment --><p>To compile:</p><ul>
<li>wsdl2h -tuddi2-typemap.dat inquire_v2.wsdl</li>
<li>soapcpp2 -I.. -pinq inquire_v2.h</li>
<li>g++ -DWITH_NONAMESPACES -I.. -o example1 example1.cpp inquire_v2.cpp inqC.cpp inqClient.cpp ../stdsoap2.cpp </li>
</ul>
</div></div><!-- contents -->
<hr class="footer">
<address class="footer">
Copyright (C) 2016, Robert van Engelen, Genivia Inc., All Rights Reserved.
</address>
<address class="footer"><small>
Converted on Mon Feb 22 2016 20:01:03 by <a target="_blank" href="http://www.doxygen.org/index.html">Doxygen</a> 1.8.10</small></address>
<br>
<div style="height: 246px; background: #DBDBDB;">
</body>
</html>
